﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;

namespace DAO
{
    public class SanVD_DAO
    {

        public static DataTable ListSo()
        {
            ChuoiKetNoi.Openconnect();
            string sql = "Select * from SanVD";
            DataTable ds = ChuoiKetNoi.laybang(sql);

            if (ds.Rows.Count == 0)
            {
                return null;

            }
            //ChuoiKetNoi.Closeconnect();
            return ds;


        }
        public static void Them(SanVD_DTO tsvd)
        {
            string sql = "INSERT INTO SanVD(MaSan,TenSan,DiaChi) VALUES('" + tsvd.MaSan1 + "','" +tsvd.TenSan1 + "','" + tsvd.DiaChi1 + "')";
            ChuoiKetNoi.exc(sql);

        }
        public static bool Xoa(string xMaSan)
        {
            String sql = "DELETE FROM SanVD WHERE MaSan='" + xMaSan + "'";
            ChuoiKetNoi.exc(sql);
            return true;

        }
        public static void CapNhat(SanVD_DTO cnsvd)
        {
            string sql = "UPDATE SanVD SET TenSan='" + cnsvd.TenSan1 + "',DiaChi='" + cnsvd.DiaChi1 + "' WHERE MaSan='"+cnsvd.MaSan1+"'";
            ChuoiKetNoi.exc(sql);

        }
    }
}
